### README for Herzog, Baron, and Gibbons (Forthcoming), "Anti-Normative 
### Messaging, Group Cues, and the Nuclear Ban Treaty"; forthcoming at The 
### Journal of Politics.

### This README details instructions and files pertaining to survey, data, and 
### analysis code for replication purposes. Please direct inquiries to 
### jonathon.baron@gmail.com

## Meta information and instructions.
# Performance assessments:
	- Measured total run time (seconds), using
		R CMD BATCH run_hbg_replication.R 2>&1 replication_out.out
		- 137.820 (see run_time outfile for machine-specific statistics).
	- Hardware used.
		- Lenovo ThinkPad X1 Carbon 5th Generation;
		- Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz;
		- Physical Memory Array; Maximum Capacity 16GB.
	- Operating system used.
		- Linux Mint 19 Tara Cinnamon 64-bit (4.10.0-38-generic).

# Dependencies:
1.) R version 3.6.3 (2020-02-09) -- "Holding the Windstock."
	- Required packages.
		- plyr
		- car
		- anesrake
		- sandwich
2.) LaTeX (for typesetting tabular output).
	- Required and recommended packages.
		- array
		- booktabs
		- float
		- makecell
		- multirow
		- siunitx

# Instructions:
1.) Set working directory to the replication-file parent directory.
	- All scripts assume ~/Downloads/hbg_replication as the parent directory.
2.) For all operating systems, the scripts/run_hbg_replication.R script may be
	executed in an R instance.
	- Open the hbg_replication.R script in R.
	- Run all commands in the console.
3.) For UNIX/UNIX-like systems (MacOS, Linux, Windows 10 Subsysten for Linux), 
it is recommended to run the script in a terminal instance.
	- Enter either
		R CMD BATCH scripts/run_hbg_replication.R 2>&1 cli_script.out
	which will produce an outfile containing command-line interface output in 
	the cli_script.out outfile; or,
		Rscript scripts/run_hbg_replication.R
	though Rscript will not echo output.
4.) Commands may also be run in an interactive R session without use of 
run_hbg_replication.R, e.g., in RStudio.
	- Working directory will have to be set manually; in the R console, enter
		setwd("~/hbg_replication")
	- The output directory will also need to be created separately; once the
	working directory has been set to the parent directory, in the R console, 
	enter
		dir.create("output")

## Directories and files.
# ./meta:
1.) hbg_instrument.pdf
	- Herzog, Baron, and Gibbons (Forthcoming) survey instrument.
	- The instrument does not describe randomization; treatment assignment was
	randomized using Qualtrics embedded data, randomized using Qualtrics'
	internal "Evenly Present Elements" algorithm. Some answer choice options
	were also randomized in order to avoid ordering effects; questions employing
	internal randomization include pid3, join_tpnw, and the row order of the 
	attitudinal outcomes battery.
2.) hbg_codebook.txt
	- Herzog, Baron, and Gibbons codebook.
		- Details coding values for embedded data and survey questions in 
		all included data files.
		- Notes variable recoding values used in cleaned experimental data
		(tpnw_data.csv), used for analysis.
3.) hbg_pap.pdf
	- Herzog, Baron, and Gibbons pre-analysis plan.
		- Details all analysis decisions, per research design pre-registered 
		with EGAP prior to collecting experimental data.

# ./data:
1.) tpnw_aware_raw.csv
	- Data from Herzog, Baron, and Gibbons YouGov study.
	- Note that some variables have been excluded as they are used in separate
	studies.
2.) tpnw_orig_income.csv
	- Data from original income coding from Herzog, Baron, and Gibbons.
	- Note that some variables have been excluded as they are used in separate
	studies.
3.) tpnw_raw.csv
	- Data from Herzog, Baron, and Gibbons experimental survey.
	- Note that some variables have been excluded as they are used in separate
	studies.

# ./output (produced by either ../scripts/hbg.sh or 
# ../scripts/run_hbg_replication.R):
1.) ./hbg_log.txt
	- Output for experimental data cleaning and analysis (produced by either 
	../scripts/hbg.sh or ../scripts/run_hbg_replication.R).
2.) ./run_time
	- Output for total run time  (produced by either ../scripts/hbg.sh or 
	../scripts/run_hbg_replication.R).
4.) ./fg%.eps
	- .eps images of figures produced by ../scripts/hbg_replication.R); 
	inventoried below.
5.) ./%_tab.tex
	- .tex files containing LaTeX tables produced by 
	../scripts/hbg_replication.R; inventoried below.

# ./scripts:
1.) run_hbg_replication.R
	- "Run file" to run replication code and produce console and run-time output 
	in R (all systems); produces
		- ../output/hbg_log.txt
			- Output for all analyses and results.
		- ../output/run_time
			- Output for total run time.
2.) helper_functions.R
	- R source file containing replication code helper functions.
3.) hbg_cleaning.R
	- Cleaning script; outputs cleaned experimental dataset including anesrake 
	weights.
		- ../data/tpnw_data.csv
			- Cleaned experimental data.
		- ../data/tpnw_aware.csv
			- Cleaned YouGov data.
4.) hbg_analysis.R
	- Analysis script; outputs analysis results in graphical, tabular, and RData
	formats.
		- ../output/fg1.eps
			- .eps image of Figure 1.
		- ../output/%_tab.tex
			- .tex files containing LaTeX markup of all tables.
				- balance_tab.tex
					- Table demonstrating covariate balance across arms.
				- main_results_tab.tex
					- Table containing main results.
				- atts_tab.tex
					- Table containing attitudinal battery results.
				- pid_support_tab.tex
					- Table containing results by partisan identification.
				- ideo_support_tab.tex
					- Table containing results by political ideology.
				- weighted_main_results_tab.tex
					- Table containing weighted main results.
		- ../output/hbg_replication_out.RData
			- .RData file containing all analysis results.
5.) hbg_group_cue.R
	- Script to produce group cue graphic.
		- hbg_fgc1.eps
			- .eps image of Figure C1.